﻿using EntityframeworkHelper.Data.EntityExtend;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.ModelConfiguration.Configuration;

namespace EntityframeworkHelper.Data.Configurations
{
    /// <summary>
    ///     复合数据实体映射配置基类
    /// </summary>
    /// <typeparam name="TComplexType">动态复合实体类型</typeparam>
    /// <typeparam name="TKey">动态主键类型</typeparam>
    public abstract class ComplexTypeConfigurationBase<TComplexType, TKey> : ComplexTypeConfiguration<TComplexType>, IEntityMapper
        where TComplexType : EntityBase<TKey>
    {
        #region IEntityMapper Members

        #region Implementation of IEntityMapper

        /// <summary>
        ///     将当前实体映射对象注册到当前数据访问上下文实体映射配置注册器中
        /// </summary>
        /// <param name="configurations">实体映射配置注册器</param>
        public void RegistTo(ConfigurationRegistrar configurations)
        {
            configurations.Add(this);
        }

        #endregion Implementation of IEntityMapper

        #endregion IEntityMapper Members
    }

    /// <summary>
    ///     Class EntityConfigurationBase.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="Tkey">The type of the tkey.</typeparam>
    public abstract class EntityConfigurationBase<T, Tkey> : EntityTypeConfiguration<T>, IEntityMapper
        where T : EntityBase<Tkey>
    {
        #region IEntityMapper Members

        /// <summary>
        ///     将当前实体映射对象注册到当前数据访问上下文实体映射配置注册器中
        /// </summary>
        /// <param name="configurations">实体映射配置注册器</param>
        public void RegistTo(ConfigurationRegistrar configurations)
        {
            configurations.Add(this);
        }

        #endregion IEntityMapper Members
    }
}